package SpringCloudBase.controller;

import SpringCloudBase.vo.UserVO;
import com.netflix.discovery.EurekaClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @ClassName ConsumerOrderController
 * @Description : 功能说明
 * @Author : LiangT
 * @Date : 2020/3/31 11:53
 */
@RestController
public class ConsumerOrderController {
    @Value("${userUrl}")
    private String userUrl="http://127.0.0.1:7900";

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/order/{id}")
    public UserVO getUser(@PathVariable Long id){
        String url ="";
//        验证使用Ribbon访问其他服务
        url="http://PROVIDER-USER/user/"+id;
        System.out.println("请求URL:"+url);
        return restTemplate.getForObject(url,UserVO.class);
    }
}
